<?php

class Zend_View_Helper_Location extends Zend_View_Helper_Abstract
{

	
	public function location(Model_Location $loc, $type)
	{
		if ($type=="mini"){
			return $this->miniLocation($loc);
		}
		else if ($type=="detail"){
			return $this->detailLocation($loc);
		}
		else if($type=="managerMini"){
			return $this->managerMini($loc);
		}
		
		
	}
	
	public function miniLocation(Model_Location $loc){
		$name= $loc->getName();
		$id= $loc->getId();
		$add= $loc->getAddress();
		$phone=$loc->getPhone();
		$image= $loc->getImage();
		$link= '/location/detail';
		$link=$link.'?id='.$id;
		
		$result=
		'<div class="DishMini selected">
			<img class="mini-img" src="'.$image.'"></img>
			<div class="DishInfo">
				<span class="DishTitle-small"><a href="'.$link.'">'.$name.'</a></span> <br />
				<span class="DishDescription-small">'.$add.'</span> <br />
				<span class="DishDescription-small">Phone: '.$phone.'</span> <br />
			</div>
		</div>';
		
		return $result;
	}
	
	public function managerMini(Model_Location $loc){
		$name= $loc->getName();
		$id= $loc->getId();
		
		$image= $loc->getImage();
		$link= '/location/detail';
		$link=$link.'?id='.$id;
	
		$result=
		'<div class="DishMini selected">
			<img class="managerDish-img" src="'.$image.'"></img>
			<div class="DishInfo">
				<span class="DishTitle-small"><a href="'.$link.'">'.$name.'</a></span> <br />
				
				<span class="manager-edit">
						<a  href="/location/edit?id='.$id.'">Edit</a>&nbsp;
						
				<a href="/location/remove?id='.$id.'">Remove</a></span> 
			</div>
		</div>';
	
		return $result;
	}
	
	public function detailLocation(Model_Location $loc){
		$name= $loc->getName();
		$id= $loc->getId();
		$add= $loc->getAddress();
		$phone=$loc->getPhone();
		$image= $loc->getImage();
		
		$result1=
		'<div class="dish">
		    <img src="'.$image.'"></img>
		    <div class="info">
				<span class="dish-title">'.$name.'</span> <br />
				<hr class="dish-bottom-line" /><br />Category <br />';
		$result12='';
			foreach ($loc->getCats() as $cat){
				$link= '/category/detail';
				$link=$link.'?id='.$cat->getId();
				$result12=$result12.'<a href='.$link.'>'.$cat->getName().'</a><br />';
			}
		
				$result2=
			'<br /><span class="dish-description">'.$add.'</span> <br />	
				<span class="dish-description">Phone: '.$phone.'</span> <br />
			</div>
		</div>
		';
		return $result1.$result12.$result2;
	}

}
